/*===== code build by mstore0.1.3 =====*/

/*===== zhbManageSystem/common#modifyUserInfo:0 =====*/
$(function(){
    var userId;
    $('.modify').click(function(){
        userId = $(this).data('id');
        $$.post('getUserInfo.json', function(resp){
            if(resp.err){
                alert(resp.err);
            }else{
                modifyWindow(resp);
            }
        },{userId: userId});
        
        
    });
    
    function modifyWindow(resp){
        $$.window.open($rtpl(function(){/*
            <div class="userModify">
                <div class="">
                    <ul>
                        {{each userInfoList as item}}
                        <li>
                            <label>{{item.name}}</label>
                            {{if item.type == "input"}}
                            <input type="text" name="{{item.parameterName}}" value="{{item.val}}">
                            {{else if item.type == "select"}}
                            <select name="{{item.parameterName}}">
                                {{each item.options as option}}
                                <option value="{{option.value}}" {{if item.val == option.value}}selected{{/if}}>{{option.text}}</option>
                                {{/each}}
                            </select>
                            {{else if item.type == "password"}}
                            <input type="password" name="{{item.parameterName}}" value="{{item.val}}">
                            {{else if item.type == "ltgt"}}
                            {{item.minRate}} &lt; <input type="text" name="{{item.parameterName}}" value="{{item.val}}"> &lt; {{item.maxRate}}
                            {{/if}}
                        </li>
                        {{/each}}
                        <li><b class="submitModify">确定</b></li>
                    </ul>
                </div>
            </div>
        */},{userInfoList: resp.userInfoList}),{
            clsName:'modifyUserInfo',
            title:'商户修改'
        });
    }
    
    $(document).on('click', '.submitModify', function(){
        var data = {};
        $('.modifyUserInfo .userModify input').each(function(){
            var name = $(this).attr('name');
            data[name] = $(this).val();
        });
        
        $('.modifyUserInfo .userModify select').each(function(){
            var name = $(this).attr('name');
            data[name] = $(this).val();
        });
        
        $$.post('submitModifyUserInfo.json', function(resp){
            if(resp.err){
                alert(resp.err);
            }else{
                location.reload();
            }
        },data);
    });
})

/*===== zhbManageSystem/merchantMana#main:0 =====*/
$$.domready('[jbtn=searchBtn]', function(){
    $$.search.bind('[jbtn=searchBtn]', {
     
        userId: '.searchBox [name=userId]',
        userName: '.searchBox [name=userName]',
        userState: '.searchBox [name=userState]',
        end: null
    });
});
